const treeModuleInit = require('./tree-module-init')
const requestParameterInit = require('./request-parameter-init')
const responseParameterInit = require('./response-parameter-init')
const {
	loadProjectData,
} = require('./load-datas')

module.exports = function(projectId, exists) {
	let {
		apiTestComp,
	} = $['components-jq']
	if (!exists) {
		apiTestComp.testServerUrl = $("#api-test-server-url")
		apiTestComp.treeComp = $("#api-test-module-tree")
		apiTestComp.formComp = $("#api-test-form")
		apiTestComp.formId = $("#api-test-form-id")
		apiTestComp.formContentType = $("#api-test-form-content-type")
		apiTestComp.formPath = $("#api-test-form-path")
		apiTestComp.formMethod = $("#api-test-form-method")
		apiTestComp.formIntro = $("#api-test-form-intro")
		apiTestComp.requestParameterComp = $("#api-test-request-parameter-list")
		apiTestComp.responseParameterComp = $("#api-test-response-parameter-list")
		treeModuleInit(apiTestComp)
		requestParameterInit(apiTestComp)
		responseParameterInit(apiTestComp)
	}
	loadProjectData(apiTestComp, projectId)
}